<?
session_start();
require_once('Local_Settings.php');
require_once('cart/inc/functions/Cart_Functions.php');
if (!(isset($_SESSION['myusername']) && $_SESSION['mypassword'] != '')) {
header ("Location: http://www.group3productions.info/main_login.php");
}
include 'config.php';
?>

<!--Alhier het systeem voor het behoud van een layout op de hele website. Alle wijzigingen aan de layout dienen te gebeuren in de header,body en footer.php bestanden. Enkel de content mag in dit bestand staan.-->
<?php include('style/header-1.php');//hieronder komt de linkerbalk met artikelen ?>
<? include('menu.php'); ?>
<?php include('style/body-2.php');//hieronder het midden van de pagina ?>
<h5><a href="show_orders.php">ALLES LATEN ZIEN</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="show_orders.php?show=2">ONBETAALD LATEN ZIEN</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="show_orders.php?show=3">ONVERZONDEN LATEN ZIEN</a></h5>
<?php

$name=$_SESSION['myusername'];
$result = mysql_query("SELECT id FROM klant WHERE email = '{$name}'");
if (!$result) {
    die("Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
$klantid=$row['id'];


if($_GET['show']=="2")
{
$table = 'factuur';

$result = mysql_query("SELECT idfactuur, factuurdatum, betaald, verzonden FROM {$table} WHERE (idklant = {$klantid}) AND betaald = '0' ORDER BY idfactuur");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

//echo "<h1>Table: {$table}</h1>";
echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";

echo "<td><b>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Factuurdatum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Betaald&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Verzonden&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
	$idcode=$row[0];
	
	
	if($row[2]==0)
	{
		$row[2]="NEE";
	}
	elseif($row[2]==1)
	{
		$row[2]="JA";
	}
	else
	{
		$row[2]="???";
	}
	
	if($row[3]==0)
	{
		$row[3]="NEE";
	}
	elseif($row[3]==1)
	{
		$row[3]="JA";
	}
	else
	{
		$row[3]="???";
	}
	
    echo "<tr>";

    foreach($row as $cell)
        echo "<td><a href=\"order_details.php?id=$idcode\">$cell</a></td>";
    echo "</tr>\n";
}
mysql_free_result($result);
echo "</table>";
}
else if ($_GET['show']=="3")
{
$table = 'factuur';

$result = mysql_query("SELECT idfactuur, factuurdatum, betaald, verzonden FROM {$table} WHERE (idklant = {$klantid}) AND verzonden = '0' ORDER BY idfactuur");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

//echo "<h1>Table: {$table}</h1>";
echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";

echo "<td><b>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Factuurdatum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Betaald&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Verzonden&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
	$idcode=$row[0];
	
	
	if($row[2]==0)
	{
		$row[2]="NEE";
	}
	elseif($row[2]==1)
	{
		$row[2]="JA";
	}
	else
	{
		$row[2]="???";
	}
	
	if($row[3]==0)
	{
		$row[3]="NEE";
	}
	elseif($row[3]==1)
	{
		$row[3]="JA";
	}
	else
	{
		$row[3]="???";
	}
	
    echo "<tr>";

    foreach($row as $cell)
        echo "<td><a href=\"order_details.php?id=$idcode\">$cell</a></td>";
    echo "</tr>\n";
}
mysql_free_result($result);
echo "</table>";
}
else
{
$table = 'factuur';

$result = mysql_query("SELECT idfactuur, factuurdatum, betaald, verzonden FROM {$table} WHERE (idklant = {$klantid}) ORDER BY idfactuur");
if (!$result) {
    die("Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);

//echo "<h1>Table: {$table}</h1>";
echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";

echo "<td><b>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Factuurdatum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Betaald&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Verzonden&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
	$idcode=$row[0];
	
	
	if($row[2]==0)
	{
		$row[2]="NEE";
	}
	elseif($row[2]==1)
	{
		$row[2]="JA";
	}
	else
	{
		$row[2]="???";
	}
	
	if($row[3]==0)
	{
		$row[3]="NEE";
	}
	elseif($row[3]==1)
	{
		$row[3]="JA";
	}
	else
	{
		$row[3]="???";
	}
	
    echo "<tr>";

    foreach($row as $cell)
        echo "<td><a href=\"order_details.php?id=$idcode\">$cell</a></td>";
    echo "</tr>\n";
}
mysql_free_result($result);
echo "</table>";
}
?>

<?php include('style/body-3.php');//hieronder de rechterbalk ?>
<? echo ( DisplayCartBald($Session_Prefix,$Currency_Symbol,$Currency_Code));?> 
<?php include('style/footer-4.php');?>